import { defineConfig } from 'umi';
import routes from './routes';

const chainWebpack: any = function (config: any) {
  // config.merge({
  //   output: {
  //     filename: '[id].[hash:5].js',
  //     chunkFilename: '[id].[hash:5].js',
  //   },
  // });
  config.plugin('extract-css').tap(() => [{
    filename: '[name].css',
    chunkFilename: '[id].[hash:5].css',
    ignoreOrder: true
  }]);
  config.output.filename('[name].js').chunkFilename('[id].[hash:5].js');
}

export default defineConfig({
  title: '移动端脚手架',
  mfsu: {},
  nodeModulesTransform: {
    type: 'none',
  },
  chainWebpack: chainWebpack,
  dynamicImport: {},
  fastRefresh: {},
  analyze: {
    analyzerMode: 'server',
    analyzerPort: 8888,
    openAnalyzer: true,
    generateStatsFile: false,
    statsFilename: 'stats.json',
    logLevel: 'info',
    defaultSizes: 'parsed',
  },
  cssLoader: {
    localsConvention: 'camelCase',
  },
  cssModulesTypescriptLoader: {},
  dva: {
    lazyLoad: true,
    disableModelsReExport: true,
  },
  antd: {
    mobile: false,
  },
  proxy: {
    "/api": {
      target: "http://localhost:3000",
      changeOrigin: true,
      pathRewrite: { '^/api': '' }
    }
  },
  ...routes,
});
